<?php
/**
 * ProductController.php
 *
 * @copyright  2023 beikeshop.com - All Rights Reserved
 * @link       https://beikeshop.com
 * @author     TL <mengwb@guangda.work>
 * @created    2023-05-26 18:57:56
 * @modified   2023-05-26 18:57:56
 */

namespace Plugin\MultiSeller\Http\Controllers\Admin;

use Beike\Admin\Http\Controllers\Controller;
use Beike\Seller\Repositories\ProductRepo;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class ProductController extends Controller
{
    /**
     * @param Request $request
     * @param int     $id
     * @return JsonResponse
     */
    public function approve(Request $request, int $id)
    {
        $status  = $request->get('status');
        $comment = $request->get('comment');

        ProductRepo::updateApprovedStatus($id, $status, $comment);

        return json_success(trans('common.success'));
    }

    /**
     * @param Request $request
     * @return array
     */
    public function needApprove(Request $request)
    {
        $ids = $request->get('ids');

        $data['need_approve'] = ProductRepo::getNeedApproveByIds($ids);

        return json_success(trans('common.success'), $data);
    }
}
